﻿using UnityEngine;
using System.Collections;

public class MainPanelManager : MonoBehaviour {
    public static MainPanelManager instance;
    public GameObject Bg;
    public GameObject chengyuPanel;
    public GameObject chengyuQiangdaPanel;
    public GameObject naojizhuanwanPanel;
    public GameObject chengyuStroyPanel;
    public GameObject aboutWePanel;
    public GameObject hintPanel;
    public GameObject NoticePanel;
    public UILabel hintContent;

    public GameObject LevelPanel;
    public GameObject ExitPanel;

    public GameObject RecePanel;
    public GameObject RankingPanel;
	// Use this for initialization
	void Start () {
        instance = this;
	}
	
	// Update is called once per frame
	void Update () {
        if( Input.GetKeyDown( KeyCode.Escape ) )
        {
            ExitPanel.SetActive( true );
        }
	}
    public void ChengYuStartOnClick()
    {        
        Bg.SetActive( false );
        //chengyuManager.Instance.DownTimer.gameObject.SetActive( false );
        //chengyuPanel.SetActive( true );       
        //Global.instance.Alert( "比赛开始！" );
        LevelPanel.SetActive( true );

    }
    public void ChengYuExit()
    {
        if( chengyuManager.Instance.QiangDao )
        {
            chengyuManager.Instance.QiangDao = false;
            chengyuPanel.SetActive( false );
            Bg.SetActive( true );
        }
        else
        {
            chengyuPanel.SetActive( false );
            LevelPanel.SetActive( true );
        }       

    }
    public void LevelStartOnClick()
    {
        LevelPanel.SetActive( false );
        chengyuManager.Instance.DownTimer.gameObject.SetActive( false );
        chengyuPanel.SetActive( true );
    }
    public void LevelExit()
    {
        LevelPanel.SetActive( false );
        Bg.SetActive( true );
    }
    public void ChengYuQiangDaStartOnClick()
    {
        Bg.SetActive( false );
        chengyuPanel.SetActive( true );
        chengyuManager.Instance.QiangDao = true;
        chengyuManager.Instance.DownTimerClick();

    }
    public void ChengYuQiangDaExit()
    {
        chengyuPanel.SetActive( false );
        chengyuManager.Instance.DownTimer.gameObject.SetActive( false );
        chengyuManager.Instance.QiangDao = false;
        Bg.SetActive( true );
    }
    public void NaoJiZhuanWanStartOnClick()
    {
        Bg.SetActive( false );
        naojizhuanwanPanel.SetActive( true );
    }
    public void NaoJiZhuanWanExit()
    {
        naojizhuanwanPanel.SetActive( false );
        Bg.SetActive( true );
    }
    public void ChengYuStroyStartOnClick()
    {
        Bg.SetActive( false );
        chengyuStroyPanel.SetActive( true );
    }
    public void ChengYuStroyExit()
    {
        chengyuStroyPanel.SetActive( false );
        Bg.SetActive( true );
    }
    public void AboutWeStartOnClick()
    {
        Bg.SetActive( false );
        aboutWePanel.SetActive( true );
    }
    public void AboutWeExit()
    {
        aboutWePanel.SetActive( false );
        Bg.SetActive( true );
    }
    //打开提示面板
    public void HintStartOnClick()
    {
        hintPanel.SetActive( true );
    }
    public void HintExit()
    {
        SetHintContent( 1 );
        hintPanel.SetActive( false );
    }
    public void SetHintContent(int id,string hint=null)
    {
        if( id == 1 )
        {
            hintContent.text = "使用此功能需要消耗15个钻石!";
        }
        else if( id == 2 )
        {
            hintContent.text = "你当前的钻石数不足15个，无法使用提示功能！";
        }
        else if( id == 3 )
        {
            hintContent.text = hint;
        }
    }

    public void NoticePanelExit()
    {
        NoticePanel.SetActive( false );
    }

    public void ConfirmExit()
    {
        Application.Quit();
    }
    public void Cancel()
    {
        ExitPanel.SetActive( false );
    }

    public void ReceStartOnClick()
    {
        Bg.SetActive( false );
        RecePanel.SetActive( true );
    }
    public void ReceExit()
    {
        RecePanel.SetActive( false );
        Bg.SetActive( true );
    }
    public void RankingStartOnClick()
    {
        Bg.SetActive( false );
        RankingPanel.SetActive( true );
        Ranking.instance.InitRankItem();
    }
    public void RankingExit()
    {
        RankingPanel.SetActive( false );
        Bg.SetActive( true );
    }
}
